class StatisticOrder
{
  public string Id { get; set; }

    public double UnitTimeRange { get; set; }

    //HIS申请单是否合格
    public string IsQualified { get; set; }

    //不合格理由
    public string NQReason { get; set; }
    /// <summary>
    /// 修改理由
    /// </summary>
    public string ModifyReason { get; set; }

    public string Timespan { get; set; }
    /// <summary>
    /// HisExamName
    /// </summary>
    public List<string> HisExamName { get; set; }

    /// <summary>
    /// 病区
    /// </summary>
    public string RoomNumberName { get; set; }
    /// <summary>
    /// 预约修改人
    /// </summary>
    public string OrderChangeDoctorId { get; set; }
    public string OrderChangeDoctorName { get; set; }
    public DateTime? LastOrderDateTime { get; set; }
    /// <summary>
    /// 紧急程度
    /// </summary>
    public int? EmergencyDegree { get; set; }
    /// <summary>
    /// 手机号
    /// </summary>
    public string Telephone { get; set; }
    /// <summary>
    /// 诊断组
    /// </summary>
    public string DiagnosisGroupName { get; set; }
    /// <summary>
    /// 住院次数
    /// </summary>
    public string InHospitalCount { get; set; }
    /// <summary>
    /// 排队号
    /// </summary>
    public string QueueNumber { get; set; }
    /// <summary>
    /// HIS部位
    /// </summary>
    public string HISBodyPartName { get; set; }
    /// <summary>
    /// HIS辅助说明
    /// </summary>
    public string HISNote { get; set; }

    public DateTime? PatientDateOfBirth { get; set; }

    public string PatientGender { get; set; }
    public string GlobalPatientId { get; set; }
    public string HospitalId { get; set; }
    public string HospitalName { get; set; }
    public string PatientName { get; set; }
    public bool? IsVIP { get; set; }
    public string PatientType { get; set; }
    public string AccessionNumber { get; set; }

    public int? Age { get; set; }
    public string AgeUnit { get; set; }

    public string AgeWithUnit
    {
        get { return Age != null ? Age + AgeUnit : null; }
    }

    public string AgeUnitCode { get; set; }
    public string PatientIdentityName { get; set; }
    /// <summary>
    /// 申请科室
    /// </summary>
    public string ApplyDepartmentId { get; set; }
    public string ApplyDepartmentName { get; set; }
    public string ApplyDoctorId { get; set; }
    public string ApplyDoctorName { get; set; }

    public DateTime? ArriveTime { get; set; }

    public string CheckInDoctorId { get; set; }
    public string CheckInDoctorName { get; set; }
    /// <summary>
    /// 是否为CT增强
    /// </summary>
    public string IsCTEnhancement { get; set; }
    /// <summary>
    /// 检查项目组合
    /// </summary>
    public string CheckItemsCombination { get; set; }
    public string DeviceAETitle { get; set; }
    public string DeviceId { get; set; }
    public string DeviceName { get; set; }
    public string ExamName { get; set; }
    public string ExamRoom { get; set; }
    public string ExecDepartmentId { get; set; }
    public string ExecDepartmentName { get; set; }
    public string ExecDoctorId { get; set; }
    public string ExecDoctorName { get; set; }
    public string AssTechId1 { get; set; }
    public string AssTechId2 { get; set; }
    public int? ImageCount { get; set; }
    public bool? IsFromHIS { get; set; }
    public string ModalityId { get; set; }
    public string ModalityName { get; set; }
    public string OrderSpecialClassDicId { get; set; }
    public string OrderSpecialClassDicName { get; set; }
    public string OrderDoctorId { get; set; }
    public string OrderDoctorName { get; set; }

    public DateTime? RegisterTime { get; set; }

    public string ReportDoctorId { get; set; }
    public string ReportDoctorName { get; set; }
    public DateTime? ScheduledEndTime { get; set; }
    public DateTime? ScheduledStartTime { get; set; }

    public DateTime? StudyDate { get; set; }

    public string StudyId { get; set; }
    public double TotalFee { get; set; }
    public DateTime? ApproveDatetime { get; set; }
    public string ApproveDoctor { get; set; }
    public string ApproveDoctorId { get; set; }
    public string FilmingRank { get; set; }

    public bool? IsPositive { get; set; }
    public string Keywords { get; set; }

    public DateTime? PrintDateTime { get; set; }

    public string PrintDoctor { get; set; }
    public string PrintDoctorId { get; set; }
    public DateTime? PublishDateTime { get; set; }

    public string PublishDoctor { get; set; }
    public string PublishDoctorId { get; set; }
    public string ReportStatus { get; set; }

    public DateTime? SubmitDateTime { get; set; }

    public string SubmitDoctor { get; set; }
    public string SubmitDoctorId { get; set; }
    public string ApplyDoctorNameWithCode { get; set; }

    /// <summary>
    /// 传染病
    /// </summary>
    public string ContagionName { get; set; }
    /// <summary>
    /// 传染病数量
    /// </summary>
    public int ContagionCount { get; set; }

    public int? Score { get; set; }
    public bool? IsCritical { get; set; }

    public string ChargeTypeName { get; set; }
    public string Impression { get; set; }

    public string PathologyNo { get; set; }
    public string ClinicalDiagnosis { get; set; }
    public string ImageDiagnosis { get; set; }
    public string ClinicalDiagnosisMethord { get; set; }
    public string PathologyResult { get; set; }
    public string OutcomeOfTherapy { get; set; }

    public DateTime? FollowUpCreateDateTime { get; set; }


    // 急诊医生初步诊断json字符串
    public string Auth { get; set; }
    public string EmergencyDoctorName { get; set; }
    public string EmergencyDoctorId { get; set; }
    public bool? Acknowledge { get; set; }
    public bool? RequireReviewingReport { get; set; }

    public string OrderTechInfo { get; set; }

    /// <summary>
    /// 质控评分的病例档案号
    /// </summary>
    public string MedicalFileNo { get; set; }
    public string ExamineStaffId { get; set; }

    /// <summary>
    /// 质控评分统计
    /// </summary>
    public int? DescriptionLogic { get; set; }
    public int? DescriptionIntegrity { get; set; }
    public int? DescriptionStandard { get; set; }
    public int? DiagnoseLogic { get; set; }
    public int? DiagnoseVeracity { get; set; }
    public int? TotalScore { get; set; }

    public string ApplyDoctorDepartmentId { get; set; }
    public string ApplyDoctorDepartmentName { get; set; }
    public string CheckInDoctorDepartmentId { get; set; }
    public string CheckInDoctorDepartmentName { get; set; }
    public string ExecDoctorDepartmentId { get; set; }
    public string ExecDoctorDepartmentName { get; set; }
    public string OrderDoctorDepartmentId { get; set; }
    public string OrderDoctorDepartmentName { get; set; }
    public string ReportDoctorDepartmentId { get; set; }
    public string ReportDoctorDepartmentName { get; set; }
    public string ApproveDoctorDepartmentId { get; set; }
    public string ApproveDoctorDepartmentName { get; set; }

    public string BodyPartNames { get; set; }
    public string ClinicalNumber { get; set; }
    public int? ExtendAge { get; set; }
    public string ExtendAgeUnitCode { get; set; }
    public string IDCard { get; set; }
    public string InpatientNumber { get; set; }
    /// <summary>
    /// 病案号
    /// </summary>
    public string MedicalRecordNumber { get; set; }
    /// <summary>
    /// 就诊流水号
    /// </summary>
    public string VisitSerialNumber { get; set; }

    public string PatientID { get; set; }
    public string PatientMergeId { get; set; }
    public string SocietyNumber { get; set; }
    public string Status { get; set; }


    public int TotalFilmAmount { get; set; }
    public int TotalImageAmount { get; set; }
    public int TotalExposalAmount { get; set; }

    public double TotalCheckFee { get; set; }
    public double TotalFilmFee { get; set; }
    public double TotalMaterialFee { get; set; }

    public string TypistId { get; set; }
    public string TypistName { get; set; }
    public string TypistDepartmentId { get; set; }
    public string TypistDepartmentName { get; set; }

    /// <summary>
    /// 是否与临床诊断相符合
    /// 0：未选择，1：不符合，2：基本符合，3：符合
    /// </summary>
    public int ClinicalConsistency { get; set; }

    /// <summary>
    /// 临床诊断符合数
    /// </summary>
    public int ClinicalConsistencyCount { get; set; }

    /// <summary>
    /// 病人年龄(年)
    /// </summary>
    public double? PatientAgeYear { get; set; }

    /// <summary>
    /// 随访符合度：未知：0，不符合：1，符合：2
    /// </summary>
    public int? FollowUpConformity { get; set; }

    /// <summary>
    /// 随访数量
    /// </summary>
    public int FollowUpCount { get; set; }

    /// <summary>
    /// 申请单数量
    /// </summary>
    public int OrderCount { get; set; }
    /// <summary>
    /// HisExam数
    /// </summary>
    public int HisExamNameCount { get; set; }

    /// <summary>
    /// HIS申请单提交时间
    /// </summary>
    public string HisOrderRequestDate { get; set; }


    public string FirstAssignmentApproveDoctorName { get; set; }
    public string FirstAssignmentApproveDoctorId { get; set; }

    public string FirstAssignmentReportDoctorId { get; set; }
    public string FirstAssignmentReportDoctorName { get; set; }


    /// <summary>
    /// 初次分配报告医师权重
    /// </summary>
    public int? FirstAssignmentReportWeights { get; set; }


    /// <summary>
    /// 初次分配审核医师权重
    /// </summary>
    public int? FirstAssignmentApproveWeights { get; set; }


    public void CalculateFilmAmounts()
    {
        var isPass = IsPassFilm();
        FilmPassAmount = isPass ? 1 : 0;
        FilmFailAmount = isPass ? 0 : 1;
        AFilmAmount = BFilmAmount = CFilmAmount = 0;
        if (!string.IsNullOrEmpty(FilmingRank))
        {
            var _FilmingRank = FilmingRank.ToUpper();
            switch (_FilmingRank)
            {
                case "A":
                    AFilmAmount = 1;
                    break;
                case "B":
                    BFilmAmount = 1;
                    break;
                case "C":
                    CFilmAmount = 1;
                    break;
            }
        }

    }


    public bool IsPassFilm()
    {
        if (FilmingRank != null)
        {
            switch (FilmingRank.ToUpper())
            {
                case "A":
                case "B":
                case "C":
                    return true;
            }
        }
        return false;
    }
    /// <summary>
    /// 总摄片数
    /// </summary>
    public int FilmingCount { get; set; }
    /// <summary>
    /// 不符合数量(废片，未评级)
    /// </summary>
    public int FilmFailAmount { get; set; }
    /// <summary>
    /// 符合数量(甲乙丙片)
    /// </summary>
    public int FilmPassAmount { get; set; }
    /// <summary>
    /// 甲片数量
    /// </summary>
    public int AFilmAmount { get; set; }
    /// <summary>
    /// 乙片数量
    /// </summary>
    public int BFilmAmount { get; set; }
    /// <summary>
    /// 丙片数量
    /// </summary>
    public int CFilmAmount { get; set; }

    /// <summary>
    /// 阳性数量
    /// </summary>
    public int PositiveAmount { get; set; }
    /// <summary>
    /// 阴性数量
    /// </summary>
    public int NegativeAmount { get; set; }
    /// <summary>
    /// 阴阳性未知数量
    /// </summary>
    public int PositiveUnknownAmount { get; set; }
    /// <summary>
    /// 申请单不合格数量
    /// </summary>
    public int QualifiedAmount { get; set; }
    /// <summary>
    /// 申请单基本合格数量
    /// </summary>
    public int BQualifiedAmount { get; set; }
    /// <summary>
    /// 申请单不合格的数量
    /// </summary>
    public int NQualifiedAmount { get; set; }

    /// <summary>
    /// 病例讨论不符合数量
    /// </summary>
    public int CaseDiscussionInconformityAmount { get; set; }

    /// <summary>
    /// 病例讨论符合数量
    /// </summary>
    public int CaseDiscussionCoincidenceAmount { get; set; }

    /// <summary>
    /// 病例讨论未知数量
    /// </summary>
    public int CaseDiscussionUnknownAmount { get; set; }

    /// <summary>
    /// 病例讨论完成数量
    /// </summary>
    public int CaseDiscussionCompleteAmount { get; set; }

    /// <summary>
    /// 病例讨论符合度
    /// </summary>
    public int? CaseDiscussionCoincidence { get; set; }

    /// <summary>
    /// AE设备
    /// </summary>
    public string StationAE { get; set; }

    /// <summary>
    /// 病例讨论状态
    /// </summary>
    public string CaseDiscussionStatus { get; set; }


    /// <summary>
    /// 是否关联影像
    /// </summary>
    public bool? IsMatch { get; set; }
    /// <summary>
    /// 计算阴阳性数量
    /// </summary>
    public void CalculatePositiveAmounts()
    {
        PositiveAmount = IsPositive == true ? OrderCount : 0;
        NegativeAmount = IsPositive == false ? OrderCount : 0;
        PositiveUnknownAmount = IsPositive.HasValue ? 0 : OrderCount;
    }

    public void CalculateQualifiedAmounts()
    {
        QualifiedAmount = IsQualified == "QU" ? OrderCount : 0;
        NQualifiedAmount = IsQualified == "NQ" ? OrderCount : 0;
        BQualifiedAmount = IsQualified == "BQ" ? OrderCount : 0;
    }

    public void CalculatePatientAgeYear()
    {
        if (RegisterTime.HasValue && PatientDateOfBirth.HasValue)
            PatientAgeYear = (double)(RegisterTime.Value - PatientDateOfBirth.Value).TotalDays / 365;
    }

    public void CalculateClinicalConsistencyCount()
    {
        ClinicalConsistencyCount = ClinicalConsistency == 2 || ClinicalConsistency == 3 ? 1 : 0;
    }


    public void CalculateContagionCount()
    {
        ContagionCount = ContagionName != null ? 1 : 0;
    }

    /// <summary>
    /// 加急的检查为1，否则为0
    /// </summary>
    public int EmergencyQuantity { get; set; }
    /// <summary>
    /// 走绿道的检查为1，否则为0
    /// </summary>
    public int ApoplexyQuantity { get; set; }
    /// <summary>
    /// 图像存在伪影（1:存在，0:不存在）
    /// </summary>
    public int FilmingArtifact { get; set; }
    /// <summary>
    /// 急诊检查（1:是急诊，0:非急诊）
    /// </summary>
    public int EmergencyCount { get; set; }
    /// <summary>
    /// 急诊是否2小时内完成（是:1，否:0）
    /// </summary>  
    public int EmergencyFinish { get; set; }
    /// <summary>
    /// 报告质控满分（是:1，否:0）
    /// </summary>
    public int ReportQualityControlFullMark { get; set; }
    /// <summary>
    /// 危急值检查（是:1，否:0）
    /// </summary>  
    public int CriticalCount { get; set; }
    /// <summary>
    /// 10分钟内上传报告（是:1，否:0）
    /// </summary>
    public int CriticalFinish { get; set; }
    /// <summary>
    /// 增强和血管成像影像检查
    /// </summary>
    public int EnhancedVascularImagingCount { get; set; }
    /// <summary>
    /// 对比剂外渗（是:1，否:0）
    /// </summary>
    public int ContrastAgentExtravasationCount { get; set; }
    /// <summary>
    /// MG检查
    /// </summary>
    public int MGCheckCount { get; set; }
    /// <summary>
    /// 乳腺BIRADS分级检查（是:1，否:0）
    /// </summary>
    public int RxBIRADS { get; set; }
    /// <summary>
    /// 前列腺PIRADS检查总数
    /// </summary>
    public int QlxBIRADSCount { get; set; }
    /// <summary>
    /// 前列腺PIRADS分级（是:1，否:0）
    /// </summary>
    public int QlxBIRADS { get; set; }


}